package com.sqx.modules.fiction.controller;

import com.sqx.common.utils.Result;
import com.sqx.modules.fiction.entity.NFiction;
import com.sqx.modules.fiction.entity.dto.GetFictionListDto;
import com.sqx.modules.fiction.service.FictionService;
import com.sqx.modules.sys.controller.AbstractController;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(value = "小说信息", tags = {"小说信息"})
@RequestMapping(value = "/system/fiction")
public class FictionController extends AbstractController {
    @Autowired
    private FictionService fictionService;

    /**
     * 查询小说列表
     * @param getFictionListDto
     * @return
     */
    @GetMapping("/getFictionList")
    public Result getFictionList(GetFictionListDto getFictionListDto){
        return fictionService.getFictionList(getFictionListDto);
    }

    /**
     * 根据id查询小说信息
     * @param id
     * @return
     */
    @GetMapping("/getFictionById/{id}")
    public Result getFictionById(@PathVariable Long id){
        return fictionService.getFictionById(id);
    }

    /**
     * 根据id更新小说信息
     * @param fiction
     * @return
     */
    @PostMapping("/updateFictionById")
    public Result updateFictionById(@RequestBody NFiction fiction){
        return fictionService.updateFictionById(fiction);
    }

    /**
     *
     * @param id
     * @return
     */
    @PostMapping("/deleteFictionById/{id}")
    public Result deleteFictionById(@PathVariable Long[] id){
        return fictionService.deleteFictionById(id);
    }

    /**
     *
     * @param fiction
     * @return
     */
    @PostMapping("/addFiction")
    public Result addFiction(@RequestBody NFiction fiction){
        return fictionService.addFiction(fiction);
    }

}
